import { reactive } from 'vue'
// 分页逻辑，需要传入页面数据请求逻辑的函数
export function usePageOption (cb) {
  const pageOpt = reactive({
    page: 1,
    pageSize: 10
  })
  const pagination = reactive({
    defaultPageSize: pageOpt.pageSize,
    defaultCurrent: pageOpt.page,
    pageSize: pageOpt.pageSize,
    current: pageOpt.page,
    total: 0,
    onCurrentChange: (page) => {
      pagination.current = pageOpt.page = page
      cb && cb()
    },
    onPageSizeChange: (size) => {
      pagination.pageSize = pageOpt.pageSize = size
      cb && cb()
    }
  })
  return {
    pageOpt,
    pagination
  }
}
